package com.dmgis.hndz.controller;

import com.dmgis.hndz.common.utils.StringUtil;
import com.dmgis.hndz.common.utils.SysResult;
import com.dmgis.hndz.pojo.SendUnitManagement;
import com.dmgis.hndz.service.SendUnitManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author pengdongdong
 * @description public
 * @date 2024-01-10
 */
@CrossOrigin
@RestController
@RequestMapping(value = "/sendUnitManagement")
public class SendUnitManagementController {

    @Autowired
    private SendUnitManagementService sendUnitManagementService;

    /**
     * 新增
     *
     * @author pengdongdong
     * @date 2024/01/10
     **/
    @PostMapping("/save")
    public SysResult insertSendUnitManagement(@RequestBody SendUnitManagement sendUnitManagement) {
        if (StringUtil.IsNullOrEmpty(sendUnitManagement.getCode())) {
            return SysResult.fail("行政编码不能为空！");
        }
        if (StringUtil.IsNullOrEmpty(sendUnitManagement.getUnitName())) {
            return SysResult.fail("发送单位不能为空！");
        }
        return sendUnitManagementService.insertSendUnitManagement(sendUnitManagement);
    }


    /**
     * 更新
     *
     * @author pengdongdong
     * @date 2024/01/10
     **/
    @PostMapping("/update")
    public SysResult updateSendUnitManagement(@RequestBody SendUnitManagement sendUnitManagement) {
        return sendUnitManagementService.updateSendUnitManagement(sendUnitManagement);
    }


}